package com.github.pig.admin.service.zhgl.community.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pig.admin.mapper.zhgl.community.CommunityInfoMapper;
import com.github.pig.admin.model.entity.SysDept;
import com.github.pig.admin.model.zhgl.community.CommunityInfo;
import com.github.pig.admin.service.zhgl.community.ICommunityInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 小区基本信息表 服务实现类
 * </p>
 *
 * @author xiaosa
 * @since 2018-06-11
 */
@Service
public class CommunityInfoServiceImpl extends ServiceImpl<CommunityInfoMapper, CommunityInfo> implements ICommunityInfoService {
    @Autowired
    private CommunityInfoMapper communityInfoMapper;

    @Override
    public List<CommunityInfo> getCommunitysByCurrentUser(String currentUserName) {
        return communityInfoMapper.getCommunitysByCurrentUser(currentUserName);
    }

    /**
     * 通过部门ID查询小区列表
     *
     * @param deptId 部门ID
     * @return 小区列表
     */
    @Override
    public List<CommunityInfo> selectListByDeptId(Integer deptId) {
        return communityInfoMapper.selectListByDeptId(deptId);
    }

    /**
     *
     * 通过部门id查询子部门下所有园区
     * @param id
     * @return CommunityInfo
     */
    @Override
    public List<CommunityInfo> getCommunityInfos(Integer id){

        return communityInfoMapper.getCommunityInfos(id) ;
    }
    /**
     * 根据当前登录人用户id获取到用户所属小区
     *
     * @param userId 用户id
     * @return 小区列表
     */
    @Override
    public List<CommunityInfo> getCommunitysByUserId(Integer userId){

        return communityInfoMapper.getCommunitysByUserId(userId) ;
    }

    @Override
    public List<SysDept> getDeptsByCurrentUser(String currentUserName) {
        return communityInfoMapper.getDeptsByCurrentUser(currentUserName);
    }
}
